package com.wzh.controll;

import com.wzh.pojo.Po.Classinfo;
import com.wzh.pojo.Req.ClassinfoReq;
import com.wzh.pojo.Resp.DataResp;
import com.wzh.service.Classser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/class")
public class classes {

	@Autowired
	private Classser classser;
	@PostMapping(value = "/classlist",produces = "application/json;charset=utf-8")
	@ResponseBody
	public DataResp getuser(@RequestBody ClassinfoReq classinfoReq){
		System.out.println(classinfoReq);
		DataResp resp = classser.get(classinfoReq);
		return resp;
	}

	@PostMapping("/addclass")
	@ResponseBody
	public result adduser(@RequestBody Classinfo classinfo){
		System.out.println(classinfo);
		boolean flag=classser.add(classinfo);
		String mes=flag!=false?"操作成功":"操作失败";
		Integer code=flag!=false?200:300;
		return new result(mes,code,classinfo);
	}
	@PostMapping("/deleteclass")
	@ResponseBody
	public result deone(@RequestBody Classinfo classinfo){
		System.out.println(classinfo);
		boolean flag=classser.delete(classinfo);
		String mes=flag!=false?"操作成功":"操作失败";
		Integer code=flag!=false?200:300;
		return new result(mes,code,classinfo);
	}

	@PostMapping("/updateclass")
	@ResponseBody
	public result update(@RequestBody Classinfo classinfo){
		System.out.println(classinfo);
		boolean flag=classser.update(classinfo);
		String mes=flag!=false?"操作成功":"操作失败";
		Integer code=flag!=false?200:300;
		return new result(mes,code,classinfo);
	}


}
